import linecache


# with open('感染性.csv', 'r+') as file:
#     content = file.readlines()
#     i2=0
#     for i in content:
#         print(i)
#         i2+=1
#         if (i2>=1)&(i2<=4):
#             print(i)
#         else:
#             pass
#     # for i in content:
#     scan_info = i.strip()
#     print(scan_info)
# with open('感染性.csv', 'r+') as file:
#     content = file.readlines()
#     for i in range(1, len(content) + 1):
#         for line in content:
#             if i <= 5:
#                 print(line)
#             else:
#                 print('大于五')
# print(i)
# print(len(content))

# todo 读取文件还得删除指定行，这样不用手动选中行数，可以一直是前X条
# import linecache
# import pandas as pd
# import numpy as np
# with open('感染性.csv', 'r+') as file:
#     content=file.readlines()
#     list=[]
#     for i in content:
#         list.append(i.strip())
#     print(list) #把数据放一个列表中

# 读取并删除读取的行,返回读取的那个数值
def read_delete_first_lines(filename, count):
    n = linecache.getline(filename, count).strip()  # 返回文件第count行数据

    with open(filename, 'r') as old_file:
        old = old_file.readlines()
    with open(filename, 'w') as new_file:
        # print(old[count:])
        # print("...............................................................")
        # [1:]去掉列表中第一个元素（下标为0），去后面的元素进行操作
        # str.join(item),str表示字符串（字符），item表示一个成员，注意括号里必须只能有一个成员
        # 例如','.join('abc')的含义是“将字符串abc中的每个成员以字符','分隔开再拼接成一个字符串”，输出结果为：'a,b,c'
        new = ''.join(old[count:])
        # print(new)
        new_file.write(new)
    return n


# begin = 1
# end = 10
# for line in range(begin, end + 1):
# n = linecache.getline('感染性.csv', 1).strip()
a = read_delete_first_lines('感染性.csv', 1)
print(a)
# print(type(a))
# print(n)
